<style type="text/css">
  .pwd {
	display: none;

  }
</style>
<div id="legend" class="">
   <legend class="">用户信息</legend>
</div>

<div class="row">

    <div class="col-sm-8" style="background:#fff;">

    <div>

           <div class="control-group col-sm-6">
              <div class="controls">
                <label class="control-label">用户名</label>
                <input type="text"   class="form-control" id='username' readonly="readonly" value="{{ user_info.username }} ">
                <p class="help-block"></p>
              </div>
            </div>

           <div class="control-group col-sm-6">
              <div class="controls">
                <label class="control-label">手机</label>
                <input type="text"  id='tel' class="form-control" maxlength="11" value="{{ user_info.tel }} ">
                <p class="help-block"></p>
              </div>
            </div>

           <div class="control-group col-sm-6">
              <div class="controls">
                <label class="control-label">注册时间</label>
                <input type="text"  id='zcrq' class="form-control" readonly="readonly" value="{{ user_info.zcrq }} ">
                <p class="help-block"></p>
              </div>
            </div>


           <div class="control-group col-sm-6">
              <div class="controls">
                <label class="control-label">Email</label>
                <input type="text"  id='email' class="form-control" maxlength="32" value="{{ user_info.email }} ">
                <p class="help-block"></p>
              </div>
            </div>


           <div class="control-group col-sm-6">
              <div class="controls">
                <label class="control-label">我的贡献</label>
                <input type="text"  id='contribu' class="form-control" readonly="readonly" value="{{ user_info.gx }} ">
                <p class="help-block"></p>
              </div>
            </div>


           <div class="control-group col-sm-6">
              <div class="controls">
                <label class="control-label">等级</label>
                <input type="text"  id='level' class="form-control" readonly="readonly">
                <p class="help-block"></p>
              </div>
            </div>



           <div class="control-group col-sm-12">
              <div class="controls">
				    <label>
				      <input type="checkbox" id='isIF'>是否修改密码？
				    </label>
              </div>
            </div>
	

           <div class="control-group col-sm-7 pwd" >
              <div class="controls">
                <label class="control-label">原密码</label>
                <input type="password" id='org_pwd' maxlength="11"  class="form-control">
                <p class="help-block"></p>
              </div>
            </div>

           <div class="control-group col-sm-7 pwd">
              <div class="controls">
                <label class="control-label">新密码</label>
                <input type="password" id ='new_pwd' maxlength="11" class="form-control" >
                <p class="help-block"></p>
              </div>
            </div>

           <div class="control-group col-sm-7 pwd">
              <div class="controls">
                <label class="control-label">密码确认</label>
                <input type="password" id ='confirm_pwd' maxlength="11" class="form-control" >
                <p class="help-block"></p>
              </div>
            </div>

            <div class="control-group col-sm-12">
              <div class="controls col-sm-3" >
                <button class="btn btn-success form-control" id ='btn_user'>提交</button>
              </div>
            </div>

    </div>
  </div>


</div>
<script type="text/javascript">


	$("#isIF").change(function() { 
		
		if ($('.pwd').css('display')=='block'){
			$('.pwd').hide()
		}else{
			$('.pwd').show()
		}
	});

	 $('#btn_user').click(function(){
	 	      username = $('#username').val()
              tel   = $('#tel').val()
              email   = $('#email').val()
              isIF = $('#isIF').is(':checked')
              org_pwd  = $('#org_pwd').val()
              new_pwd  = $('#new_pwd').val()
              confirm_pwd= $('#confirm_pwd').val()
              if(isIF==true && (new_pwd!=confirm_pwd || org_pwd =='' ||new_pwd=='')){
                alert('密码不能为空或两次密码不一致！')
                return 
              }
            let list = {
              'username':username,
              'tel': tel,
              'email': email,
              'isIF': isIF,
              'org_pwd' :org_pwd,
              'new_pwd' :new_pwd,
              'confirm_pwd' : confirm_pwd
             }

             $.ajax({
              //请求方式
                  type : "POST",
                  //数据类型
                  dataType: 'json',
                  //请求地址
                  url : "/user_change",
                  //数据，json字符串
                  data : list,
                  //请求成功
                  success : function(rs) {
                    alert(rs.mes)

                  },
                  //请求失败，包含具体的错误信息
                  error : function(e){
                      alert(e)
                  }
              });


          });
</script>